package com.jframe.cfg.service.impl;


import java.util.ArrayList;
import java.util.List;

import com.jframe.cfg.model.RoleDatasrc;
import com.jframe.cfg.service.RoledataSrcService;
import com.jframe.sys.orm.service.impl.BaseServiceImpl;
import com.jframe.sys.utils.StringUtil;

public class RoledataSrcServiceImpl extends BaseServiceImpl<RoleDatasrc> implements RoledataSrcService {

	@Override
	public RoleDatasrc getRoleDatasrcByProperties(int roleId, String iframeId,String tabId,
			int datasrcId) {
		// TODO Auto-generated method stub
		List paramlist = new ArrayList();
		String hql =" from RoleDatasrc where roleId = ? and iframeId = ? and datasrcId = ?";
		paramlist.add(roleId);
		paramlist.add(iframeId);
		paramlist.add(datasrcId);
		if(StringUtil.null2Space(tabId).equals("")){
			hql += " and tabId=? ";
			paramlist.add(tabId);
		}
		List<RoleDatasrc> list = this.dao.find(hql,paramlist.toArray());
		return list.size()>0 ? list.get(0):new RoleDatasrc();
	}

	@Override
	public RoleDatasrc getRoleDatasrcByProperties(int roleId, String iframeId,
			String tabId) {
		// TODO Auto-generated method stub
		String hql =" from RoleDatasrc where roleId = ? and iframeId = ? and tabId=?";
		List<RoleDatasrc> list = this.dao.find(hql, new Object[]{roleId,iframeId,tabId});
		return list.size()>0 ? list.get(0):new RoleDatasrc();
	}

	
}
